/*
 * Appainter.java
 *
 * Copyright (C) 2009 Francesco Brisa
 *
 * This file is part of AirportPainter.
 *
 * AirportPainter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * AirportPainter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License V.3 for more details.
 *
 * You should have received a copy of the GNU General Public License V.3
 * along with AirportPainter.  If not, see <http://www.gnu.org/licenses/>.
 *
 * http://www.gnu.org/licenses/gpl-3.0.html
 *
 * email at:
 * fbrisa@gmail.com  or  fbrisa@yahoo.it
 *
 */
package airportpainter;

import airportpainter.earth.Earth;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;

/**
 *
 * @author francesco
 */
public class Appainter extends javax.swing.JFrame implements PropertyChangeListener {

    public void setAirportID(String airportID) {
        jTextFieldAirportID.setText(
            airportID
        );

    }

    private void addSP(String path) {
        if (! jTextFieldFGSceneriesFolders.getText().equals("")) {
            jTextFieldFGSceneriesFolders.setText(
                jTextFieldFGSceneriesFolders.getText()+","
            );
        }

        jTextFieldFGSceneriesFolders.setText(
            jTextFieldFGSceneriesFolders.getText()+path
        );
    }

    public void setSceneryPaths(List<String> sceneryPath) {
        jTextFieldFGSceneriesFolders.setText("");
        for (String path : sceneryPath) {
            addSP(path);
        }
    }

    /** Creates new form Appainter */
    public Appainter() {
        initComponents();

        jTextFieldFGDataFolder.setText(
            APConfiguration.getFgfsDataPath()
        );
        


        jTextFieldOutputFolder.setText(
            new File(APConfiguration.outputFolder).getAbsolutePath()
        );

        jCheckBoxDSOAP.setSelected(
            APConfiguration.drawObjectsInAirport
        );
        jCheckBoxDSOMP.setSelected(
            APConfiguration.drawObjectsInMap
        );
        jCheckBoxDTMP.setSelected(
            APConfiguration.drawTerrainInMap
        );
        
        
        

        checkIfToReloadData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextFieldFGDataFolder = new javax.swing.JTextField();
        jButtonChooseFGDataFolder = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldAirportID = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldOutputFolder = new javax.swing.JTextField();
        jButtonChooseOutputFolder = new javax.swing.JButton();
        jButtonGenerate = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldRange = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabelProgress = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jCheckBoxDSOMP = new javax.swing.JCheckBox();
        jCheckBoxDSOAP = new javax.swing.JCheckBox();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldFGSceneriesFolders = new javax.swing.JTextField();
        jButtonAddFGSceneryFolder = new javax.swing.JButton();
        jCheckBoxDTMP = new javax.swing.JCheckBox();
        jCheckBoxAddName = new javax.swing.JCheckBox();
        jLabelAction = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Airport Painter V. 0.2");

        jTextFieldFGDataFolder.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldFGDataFolderFocusLost(evt);
            }
        });

        jButtonChooseFGDataFolder.setText("...");
        jButtonChooseFGDataFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChooseFGDataFolderActionPerformed(evt);
            }
        });

        jLabel2.setText("FlightGear data folder:");

        jLabel1.setText("Airport ID:");

        jTextFieldAirportID.setText("KSFO");

        jLabel3.setText("Output folder:");

        jButtonChooseOutputFolder.setText("...");
        jButtonChooseOutputFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonChooseOutputFolderActionPerformed(evt);
            }
        });

        jButtonGenerate.setText("Generate");
        jButtonGenerate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenerateActionPerformed(evt);
            }
        });

        jLabel4.setText("Range:");

        jTextFieldRange.setText("0");

        jLabel5.setText("Nm.");

        jLabelProgress.setText("...");

        jLabel8.setText("Progress:");

        jCheckBoxDSOMP.setText("Draw shared objects in map page (pylons etc...)");

        jCheckBoxDSOAP.setText("Draw shared objects in first page (Hangars etc...)");

        jLabel6.setText("FlightGear scenery folders:");

        jTextFieldFGSceneriesFolders.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldFGSceneriesFoldersFocusLost(evt);
            }
        });

        jButtonAddFGSceneryFolder.setText("...");
        jButtonAddFGSceneryFolder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddFGSceneryFolderActionPerformed(evt);
            }
        });

        jCheckBoxDTMP.setText("Draw Terrain in map page (grass, oceans, urban, etc...)");

        jCheckBoxAddName.setText("Add airport name to output file");

        jLabelAction.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelAction.setText("...");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel6)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jTextFieldRange, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jCheckBoxDSOAP, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                                    .addComponent(jCheckBoxDSOMP, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldFGDataFolder, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                                    .addComponent(jTextFieldOutputFolder, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                                    .addComponent(jTextFieldFGSceneriesFolders, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                                    .addComponent(jCheckBoxDTMP, javax.swing.GroupLayout.Alignment.LEADING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jButtonAddFGSceneryFolder)
                                    .addComponent(jButtonChooseOutputFolder)
                                    .addComponent(jButtonChooseFGDataFolder)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jTextFieldAirportID, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCheckBoxAddName))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(94, 94, 94)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonGenerate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabelProgress)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelAction)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldFGDataFolder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonChooseFGDataFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldFGSceneriesFolders, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAddFGSceneryFolder))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(jCheckBoxDSOAP)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBoxDSOMP))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jTextFieldAirportID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCheckBoxAddName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jTextFieldOutputFolder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonChooseOutputFolder))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jTextFieldRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxDTMP)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelProgress)
                        .addComponent(jLabelAction)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonGenerate)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGenerateActionPerformed

        final Appainter appainter=this;
        
        jButtonGenerate.setEnabled(false);
        Thread nt=new Thread() {
            @Override
            public void run() {

                String paths[]=jTextFieldFGSceneriesFolders.getText().split(",");

                ArrayList<String> sceneryPath=new ArrayList<String>();
                sceneryPath.addAll(Arrays.asList(paths));

                APConfiguration.sceneryPath=sceneryPath;

//                APConfiguration.addFgfsSceneryPath(
//                    jTextFieldFGDataFolder.getText()+"/Scenery"
//                );
                    
                Main.getPropertyChangeSupport().removePropertyChangeListener(appainter);
                Main.getPropertyChangeSupport().addPropertyChangeListener(appainter);
                
                Main.generate(
                    jTextFieldAirportID.getText(),
                    new Double(jTextFieldRange.getText()).doubleValue(),
                    jTextFieldOutputFolder.getText()+"/",
                    "FFFFFF",
                    jCheckBoxDSOAP.isSelected(),
                    jCheckBoxDSOMP.isSelected(),
                    jCheckBoxDTMP.isSelected(),
                    jCheckBoxAddName.isSelected()
                );

                jButtonGenerate.setEnabled(true);

            }
        };
        nt.start();

        // Write properties file.
        java.util.Properties properties = new java.util.Properties();

        try {
            properties.setProperty("fgroot", APConfiguration.getFgfsDataPath());
            properties.setProperty("airport_id", jTextFieldAirportID.getText());
            properties.setProperty("output_folder", jTextFieldOutputFolder.getText() );
            if (jCheckBoxDSOAP.isSelected()) {
                properties.setProperty("drawObjectsInAirport", "true");
            } else {
                properties.setProperty("drawObjectsInAirport", "false");
            }
            if (jCheckBoxDSOMP.isSelected()) {
                properties.setProperty("drawObjectsInMap", "true");
            } else {
                properties.setProperty("drawObjectsInMap", "false");
            }
            if (jCheckBoxDTMP.isSelected()) {
                properties.setProperty("drawTerrainInMap", "true");
            } else {
                properties.setProperty("drawTerrainInMap", "false");
            }

            properties.setProperty("sceneries", jTextFieldFGSceneriesFolders.getText());

            properties.storeToXML(new FileOutputStream(System.getProperty("user.home")+"/.appPainter.xml"), "Appainter for FlightGear config.");
        } catch (IOException e) {
        }



    }//GEN-LAST:event_jButtonGenerateActionPerformed

    private void jButtonChooseFGDataFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChooseFGDataFolderActionPerformed
        JFileChooser jfc=new JFileChooser(jTextFieldFGDataFolder.getText());
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        int returnVal = jfc.showOpenDialog(jTextFieldFGDataFolder);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            jTextFieldFGDataFolder.setText(jfc.getSelectedFile().getAbsolutePath());
            checkIfToReloadData();
        }
    }//GEN-LAST:event_jButtonChooseFGDataFolderActionPerformed

    private void jTextFieldFGDataFolderFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldFGDataFolderFocusLost
        checkIfToReloadData();
    }//GEN-LAST:event_jTextFieldFGDataFolderFocusLost

    private void jButtonChooseOutputFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChooseOutputFolderActionPerformed
        JFileChooser jfc=new JFileChooser(jTextFieldOutputFolder.getText());
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        int returnVal = jfc.showOpenDialog(jTextFieldOutputFolder);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            jTextFieldOutputFolder.setText(jfc.getSelectedFile().getAbsolutePath());
        }
    }//GEN-LAST:event_jButtonChooseOutputFolderActionPerformed

    private void jTextFieldFGSceneriesFoldersFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldFGSceneriesFoldersFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldFGSceneriesFoldersFocusLost

    private void jButtonAddFGSceneryFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddFGSceneryFolderActionPerformed

        String lastPath="";
        if (APConfiguration.sceneryPath.size()>0) {
            lastPath=APConfiguration.sceneryPath.get(
                APConfiguration.sceneryPath.size()-1
            );
        }

        JFileChooser jfc=new JFileChooser(lastPath);
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        int returnVal = jfc.showOpenDialog(jTextFieldFGSceneriesFolders);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            addSP(jfc.getSelectedFile().getAbsolutePath());
        }
    }//GEN-LAST:event_jButtonAddFGSceneryFolderActionPerformed

    private boolean checkIfToReloadData() {
        if (
            (! jTextFieldFGDataFolder.getText().equals( APConfiguration.getFgfsDataPath()  ) ) ||
            Earth.getAirports().isEmpty()

        ) {
            APConfiguration.setFgfsDataPath(jTextFieldFGDataFolder.getText());
            Main.loader.loadAll();
            return true;
        }
        
        return false;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAddFGSceneryFolder;
    private javax.swing.JButton jButtonChooseFGDataFolder;
    private javax.swing.JButton jButtonChooseOutputFolder;
    private javax.swing.JButton jButtonGenerate;
    private javax.swing.JCheckBox jCheckBoxAddName;
    private javax.swing.JCheckBox jCheckBoxDSOAP;
    private javax.swing.JCheckBox jCheckBoxDSOMP;
    private javax.swing.JCheckBox jCheckBoxDTMP;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabelAction;
    private javax.swing.JLabel jLabelProgress;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JTextField jTextFieldAirportID;
    private javax.swing.JTextField jTextFieldFGDataFolder;
    private javax.swing.JTextField jTextFieldFGSceneriesFolders;
    private javax.swing.JTextField jTextFieldOutputFolder;
    private javax.swing.JTextField jTextFieldRange;
    // End of variables declaration//GEN-END:variables

    
    
    // caching notify images
    HashMap<String, ImageIcon> notifyImages=new HashMap<String, ImageIcon>();
    private ImageIcon getNotifyImage(String name) {
        if (! notifyImages.containsKey(name)) {
            notifyImages.put(name, new ImageIcon(getClass().getResource(Main.imgFolder+"notification/"+name)));
        }
        
        return notifyImages.get(name);
    }
    
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        
        if (evt.getPropertyName().equals("text")) {
            jLabelProgress.setText((String) evt.getNewValue());            
        }

        if (evt.getPropertyName().equals("max")) {
            jProgressBar1.setMaximum((Integer) evt.getNewValue());
        }

        if (evt.getPropertyName().equals("value")) {            
            jProgressBar1.setValue((Integer) evt.getNewValue());
        }
        if (evt.getPropertyName().equals("finished")) {            
            jProgressBar1.setValue(0);
            jLabelProgress.setText("done");                        
            jLabelAction.setIcon(getNotifyImage("done.png"));
        }
                
        
        if (evt.getPropertyName().equals("action")) {
            jLabelAction.setText((String) evt.getNewValue());
            
            if (evt.getNewValue().equals("createSheetsName")) {
                jLabelAction.setIcon(getNotifyImage("page_white_acrobat.png"));
            }
            
        }
        if (evt.getPropertyName().equals("mapCreator")) {
            jLabelAction.setText((String) evt.getNewValue());
            if (evt.getNewValue().equals("drawAnAirport")) {
                jLabelAction.setIcon(getNotifyImage("airport.png"));
            } else if (evt.getNewValue().equals("drawTerrain")) {
                jLabelAction.setIcon(getNotifyImage("map.png"));
            } else if (evt.getNewValue().equals("drawObjects")) {
                jLabelAction.setIcon(getNotifyImage("building.png"));
            } else if (evt.getNewValue().equals("drawTheNavaids")) {
                jLabelAction.setIcon(getNotifyImage("net.png"));
            } else if (evt.getNewValue().equals("drawTexts")) {
                jLabelAction.setIcon(getNotifyImage("label.png"));
            }
            
        }
        try {
            Thread.sleep(5);
        } catch (InterruptedException ex) {}
        
        
    }

}
